package bank;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Menu extends JPanel implements ActionListener {
    private Atm frame;
    private Icon btnSave = Util.getIcon("/images/buttonSave.jpg");
    private Icon btnGet = Util.getIcon("/images/buttonGet.jpg");
    private Icon btnFind = Util.getIcon("/images/buttonFind.jpg");
    private Icon btnOff = Util.getIcon("/images/buttonOff.jpg");
    JButton imageBtn1 = new JButton(btnSave);
    JButton imageBtn2 = new JButton(btnGet);
    JButton imageBtn3 = new JButton(btnFind);
    JButton imageBtn4 = new JButton(btnOff);

    public Menu(Atm frame){
       this.frame=frame;
        this.setLayout(null);
        this.setOpaque(false);
        JLabel menu=new JLabel("菜单");
        menu.setBounds(50,50,100,50);
        this.add(menu);



        imageBtn1.setBounds(300,400,140,50);
        this.add(imageBtn1);
        imageBtn1.addActionListener(this);
        imageBtn2.setBounds(600,400,140,50);
        this.add(imageBtn2);
        imageBtn2.addActionListener(this);
        imageBtn3.setBounds(300,500,140,50);
        this.add(imageBtn3);
        imageBtn3.addActionListener(this);
        imageBtn4.setBounds(600,500,140,50);
        this.add(imageBtn4);
        imageBtn4.addActionListener(this);

    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == imageBtn4) {
            frame.switchPanel("login");
        }else if (e.getSource() == imageBtn1){
            frame.switchPanel("saveMoney");
        }else if (e.getSource() == imageBtn2){
            frame.switchPanel("getMoney");
        }else if (e.getSource() == imageBtn3){
            frame.switchPanel("findMoney");
        }
    }
}
